package com.hainatong.jcmvvmbase.mainhome.fragment;

import android.view.View;
import androidx.recyclerview.widget.LinearLayoutManager;
import com.blankj.utilcode.util.ToastUtils;
import com.hainatong.jcmvvmbase.Constants;
import com.hainatong.jcmvvmbase.MvvmLazyFragment;
import com.hainatong.jcmvvmbase.R;
import com.hainatong.jcmvvmbase.databinding.FragmentListViewBinding;
import com.hainatong.jcmvvmbase.mainhome.adapter.SubFunctionAdapter;
import com.hainatong.jcmvvmbase.mainhome.entity.FunctionEntity;
import com.hainatong.mvvmbase.base.NoViewModel;

import java.util.ArrayList;
import java.util.List;

public class WorkMgrFragment extends MvvmLazyFragment<FragmentListViewBinding, NoViewModel>
{
    private SubFunctionAdapter adapter;

    @Override
    public int getLayoutId()
    {
        return R.layout.fragment_list_view;
    }

    @Override
    public int getBindingVariable()
    {
        return 0;
    }

    @Override
    protected void onRetryBtnClick()
    {
    }

    @Override
    protected void initView(View view)
    {
        adapter = new SubFunctionAdapter();
        viewDataBinding.recyclerview.setLayoutManager(new LinearLayoutManager(getActivity()));
        viewDataBinding.recyclerview.setHasFixedSize(true);
        viewDataBinding.recyclerview.setAdapter(adapter);
        List<FunctionEntity> funList = new ArrayList<>();
        funList.add(new FunctionEntity(getString(R.string.job_handle),""+Constants.FUN_ZHIBANJIAOJIE,R.mipmap.ic_job_handover));
        funList.add(new FunctionEntity(getString(R.string.ship_handle),""+Constants.FUN_UPDOWNJIAOJIE,R.mipmap.ic_up_down_board));
        funList.add(new FunctionEntity(getString(R.string.resign_handle),""+Constants.FUN_LIZHIJIAOJIE,R.mipmap.ic_resign));
        funList.add(new FunctionEntity(getString(R.string.my_handle),""+ Constants.FUN_MYJIAOJIE,R.mipmap.ic_handover_record));

        adapter.setList( funList );
        adapter.setOnItemClickListener((adapter1, view1, position) -> {

            switch ( Integer.parseInt( adapter.getItem(position).getContentTag() ) )
            {
                case Constants.FUN_ZHIBANJIAOJIE:

                    break;
                case Constants.FUN_UPDOWNJIAOJIE:

                    break;
                case Constants.FUN_LIZHIJIAOJIE:

                    break;
                case Constants.FUN_MYJIAOJIE:

                    break;
            }
            ToastUtils.showShort( adapter.getItem(position).getTitle() );
        });
    }

}
